package com.sgsg.delegatemode;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        SubjectC subjectC = new SubjectC();
        subjectC.addObserver(new ObserverA(subjectC,"观察者一"));
        subjectC.addObserver(new ObserverB(subjectC,"观察者二"));

        subjectC.setSubjectState("过来开会啦！");
        subjectC.Notify();

        subjectC.toSubjectB();
        subjectC.addObserver(new ObserverA(subjectC,"观察者一"));
        subjectC.addObserver(new ObserverB(subjectC,"观察者二"));
        subjectC.setSubjectState("我委托subjectB来通知你们了");
        subjectC.Notify();

    }
}
